<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="text" id="ceshi">
    <span id="info"></span>
    <script>
        var ceshi = document.querySelector('#ceshi')
        var info = document.querySelector('#info')
        ceshi.oninput = function(){
            var val = this.value;
            var check = function(value){
                //长度必须要超过5
                if(value.length > 5){
                    return true 
                }else{
                    return false 
                }
            }
            var checkResult = check(val)
            if(checkResult == true){
                info.innerHTML = '验证通过'
                info.style.color = 'green'
            }else{
                info.innerHTML = '验证失败'
                info.style.color = 'red'
            }
        }
    </script>
</body>
</html>